$package("boc.report");
boc.report.ClsReportXML = ClsReportXML;
$crx = ClsReportXML.prototype;
function ClsReportXML(aRptFile){
	if(aRptFile == null)
		this.RptFile   = '/report/report.htm';
	else
		this.RptFile = aRptFile;
	this.RptXml = false;
}

$crx.newRptDoc = function (){
	var dom = false;
	try{
		dom=new ActiveXObject("msxml2.DOMDocument"); 
		dom.async = false; 
		dom.resolveExternals = false; 
	}catch(e){
		alert("\u9519\u8bef:"+e.message);
		return false;
	}
	//dom.appendChild(dom.createProcessingInstruction("xml","version='1.0' encoding='gb2312'"));
	var rootnode = dom.appendChild(dom.createElement("rep"));
	this.RptXml = dom;
	return rootnode.appendChild(dom.createElement("xmldata"));
}

$crx.newBand = function (RptDoc,bandName){
	var childnode =RptDoc.appendChild(this.RptXml.createElement("band"));
	var attrnode=this.RptXml.createAttribute("ID");
	attrnode.nodeValue=bandName;
	childnode.attributes.setNamedItem(attrnode);
	return childnode;
}

$crx.newRow = function (band,fldNames,fldVals){
	var rowN = band.appendChild(this.RptXml.createElement("row"));
	for(var i=0;i<fldNames.length;i++){
		var fldN = rowN.appendChild(this.RptXml.createElement("ob"));
		var tmpEl = this.RptXml.createElement("on");
		tmpEl.nodeTypedValue=fldNames[i];
		fldN.appendChild(tmpEl);
		tmpEl = this.RptXml.createElement("ov");
		tmpEl.nodeTypedValue=fldVals[i]!=""?fldVals[i]:"null";
		fldN.appendChild(tmpEl);
	}	
}

$crx.getXmlStr = function (){
	if(!this.RptXml){
		return ""; 
	}else{
		return '<?xml version="1.0" encoding="gb2312"?>'+this.RptXml.xml;
	}
}